#include <stdio.h>
long int data[5000001];


int qsort(int a,int b){
	int left=a;
	int right=b;
	long int set=data[a];
	while(left<right){
		while(left<right&&data[right]>=set)right--;
		data[left]=data[right];
		while(left<right&&data[left]<=set)left++;
		data[right]=data[left];
	}
	data[left]=set;
	return left;
}

void search(int a,int b,int n){
	int m=qsort(a,b);
	if(m==n)printf("%ld",data[m]);
	if(m>n)search(a,m-1,n);
	if(m<n)search(m+1,b,n);
	return;
}

int main(void){
	int a,b;
	scanf("%ld%ld",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%ld",&data[i]);
	}
	search(0,a-1,b);
	return 0;
}
